<template>
  <div class="panel_h">
    <el-form
      :model="form"
      :rules="rules"
      ref="ruleForm"
      label-width="170px"
      label-position="left"
    >
      <div class="flexrowbetween pt_10 borderb mt_20">
        <div class="c_000">次数设置</div>
        <div class="c_primary f-14 commhover" v-if="sqtype" @click="handleSq(1, 0)">
          收起 <i class="el-icon-arrow-up"></i>
        </div>
        <div class="c_primary f-14 commhover" v-else @click="handleSq(1, 1)">
          展开 <i class="el-icon-arrow-down"></i>
        </div>
      </div>
      <div class="pl_20 pt_20  bg_F8F8F8 pb_10" v-if="sqtype">
        <el-form-item label="抽奖门槛：" prop="game_limit_num">
          活动成绩达到
          <el-input style="width:100px"
            placeholder=""
            v-model="form.game_limit_num"
            oninput="if(value > 100) value = 100; if(value < 0 || value == '' || value == null) value = 0;"
            :maxlength="3"
            :minlength="1"
          /> 分，即为挑战成功可抽奖
        </el-form-item>
        <el-form-item label="每人抽奖总次数：" prop="all_num">
          <!-- @focus="focus"
            @blur="changeInput"
            @input="handlerChange" -->
          <el-input
            placeholder="每人抽奖总次数"
            v-model="form.all_num"
            oninput="if(value > 100) value = 100; if(value < 0 || value == '' || value == null) value = 0;"
            :maxlength="3"
            :minlength="1"
          />
        </el-form-item>
        <el-form-item label="每人每天抽奖次数：" prop="day_num">
          <el-input
            placeholder="每人每天抽奖次数"
            v-model="form.day_num"
            oninput="if(value > 100) value = 100; if(value < 0 || value == '' || value == null) value = 0;"
            :maxlength="3"
            :minlength="1"
          />
        </el-form-item>
        <el-form-item label="每人中奖次数：" prop="win_num">
          <el-input
            placeholder="每人中奖次数"
            v-model="form.win_num"
            oninput="if(value > 100) value = 100; if(value < 0 || value == '' || value == null) value = 0;"
            :maxlength="3"
            :minlength="1"
          />
        </el-form-item>
        <el-form-item label="每人每项中奖次数：" prop="one_win_num">
          <el-input
            placeholder="每人每项中奖次数"
            v-model="form.one_win_num"
            oninput="if(value > 100) value = 100; if(value < 0 || value == '' || value == null) value = 0;"
            :maxlength="3"
            :minlength="1"
          />
        </el-form-item>
        <el-form-item label="首次登录抽奖次数：" prop="num">
          <el-input
            placeholder="首次登录抽奖次数"
            v-model="form.num"
            oninput="if(value > 100) value = 100; if(value < 0 || value == '' || value == null) value = 0;"
            :maxlength="3"
            :minlength="1"
          />
        </el-form-item>
        <el-form-item label="每人每日抽奖获得次数:" prop="user_day_num">
          <el-input
            :disabled='peoperdisable'
            placeholder="每人每日抽奖获得次数"
            v-model="form.user_day_num"
            oninput="if(value > 100) value = 100; if(value < 0 || value == '' || value == null) value = 0;"
            :maxlength="3"
            :minlength="1"
          />
        </el-form-item>
        <el-form-item label="获得额外机会：" prop="is_task">
          <el-radio-group v-model="form.is_task" @change="save">
            <el-radio
              v-for="(item, index) in statusList"
              :label="item.id"
              :key="index"
              >{{ item.name }}</el-radio
            >
          </el-radio-group>
        </el-form-item>
        <el-form-item label="" v-if="form.is_task == 1">
          <div style="padding-left: 26px">
            每人每天转发<el-input readonly
              :value="1"
              type="number"
              size="small"
              :maxlength="5"
              class="plr_9"
              style="width: 100px"
            />
            次可获得<el-input
              v-model="form.forward_num"
              type="number"
              size="small"
              :maxlength="5"
              class="plr_9"
              style="width: 100px"
            />次抽奖机会， 任务上限为<el-input
              v-model="form.forward_limit_num"
              type="number"
              size="small"
              :maxlength="5"
              class="plr_9"
              style="width: 100px"
            />
          </div>
          <div>
            每人每天浏览广告<el-input
              readonly
              :value="1"
              type="number"
              size="small"
              :maxlength="5"
              class="plr_9"
              style="width: 100px"
            />
            次可获得<el-input
              v-model="form.advert_num"
              type="number"
              size="small"
              :maxlength="5"
              class="plr_9"
              min="0"
              max="100"
              style="width: 100px"
            />次抽奖机会， 任务上限为<el-input
              v-model="form.advert_limit_num"
              type="number"
              size="small"
              min="0"
              max="100"
              class="plr_9"
              style="width: 100px"
            />
          </div>
        </el-form-item>
      </div>

      <div class="flexrowbetween pt_10 borderb mt_42">
        <div class="c_000">全局设置</div>
        <div class="c_primary f-14 commhover" v-if="sqtype2" @click="handleSq(2, 0)">
          收起 <i class="el-icon-arrow-up"></i>
        </div>
        <div class="c_primary f-14 commhover" v-else @click="handleSq(2, 1)">
          展开 <i class="el-icon-arrow-down"></i>
        </div>
      </div>
      <div class="pl_20 pt_20 bg_F8F8F8 pb_10" v-if="sqtype2">
        <el-form-item label="首次抽空概率：">
          <el-input
            placeholder=""
            v-model="form.empty_chance"
            type="number"
            min="0"
            max="100"
            class="pr_10"
            style="width: 120px"
            :maxlength="5"
          />
          %
        </el-form-item>
        <el-form-item label="抽奖模式：">
          <el-radio-group v-model="form.type">
            <el-radio :label="2">按人流量发放</el-radio>
            <el-radio :label="1">时间均匀发放</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="总中奖率：" v-if="form.type==2">
          <el-input
            v-model="form.mode_data.chance"
            type="number"
            class="pr_10"
            style="width: 120px"
            :maxlength="5"
          />
          %
        </el-form-item>
        <el-form-item label="奖品分期投放：">
          <el-radio-group v-model="form.mode_data.time">
            <el-radio
              v-for="(item, index) in fqlist"
              :key="index"
              :label="item.id"
              >{{ item.name }}</el-radio
            >
          </el-radio-group>
        </el-form-item>
      </div>
      <!-- 安全设置 -->
      <div class="flexrowbetween pt_10 borderb mt_42">
        <div class="c_000">安全设置</div>
        <div class="c_primary f-14 commhover" v-if="sqtype3" @click="handleSq(3, 0)">
          收起 <i class="el-icon-arrow-up"></i>
        </div>
        <div class="c_primary f-14 commhover" v-else @click="handleSq(3, 1)">
          展开 <i class="el-icon-arrow-down"></i>
        </div>
      </div>
      <div class="pl_20 pt_20 bg_F8F8F8 pb_10" v-if="sqtype3">
        <el-form-item label="禁止风险用户访问">
          <el-radio-group v-model="form.is_safe">
            <el-radio
              v-for="(item, index) in statusList"
              :key="index"
              :label="item.id"
              >{{ item.name }}</el-radio
            >
          </el-radio-group>
        </el-form-item>
        <el-form-item label="限制参与地区">
          <el-radio-group v-model="form.is_limit">
            <el-radio
              v-for="(item, index) in statusList"
              :key="index"
              :label="item.id"
              >{{ item.name }}</el-radio
            >
          </el-radio-group>
        </el-form-item>
        <template v-if="form.is_limit">
          <Citys ref="citys" title="限制地区" :info='citysParams' @changeCity="changeCity" />
        </template>
      </div>
    </el-form>
    <el-form :model="zlform"
      :rules="zlrules"
      ref="ruleForm"
      label-width="170px"
      label-position="left"
    >
      <!-- 广告设置 -->
      <div class="flexrowbetween pt_10 borderb mt_42">
        <div class="c_000 fw_5">抽奖助力</div>
        <div class="flex aligncenter">
          <div class="c_primary f-14 commhover" v-if="sqtype4" @click="handleSq(4, 0)">
            收起 <i class="el-icon-arrow-up"></i>
          </div>
          <div class="c_primary f-14 commhover" v-else @click="handleSq(4, 1)">
            展开 <i class="el-icon-arrow-down"></i>
          </div>
        </div>
      </div>
      <div class="p_20 bg_F8F8F8" v-if="sqtype4">
        <el-form-item label="开启助力：">
          <el-radio-group v-model="zlform.status">
            <el-radio
              v-for="(item, index) in statusList"
              :key="index"
              :label="item.id"
              >{{ item.name }}</el-radio
            >
          </el-radio-group>
        </el-form-item>
        <template  v-if="zlform.status==1">
          <el-form-item label="助力方式：" prop="type" class="mb_10">
            <el-select v-model="zlform.type" placeholder="请选择助力方式">
              <el-option
                v-for="(item, index) in helpList"
                :key="index"
                :label="item"
                :value="index"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="微信号：" v-if="zlform.type==2" class="mb_10">
            <el-input  v-model="zlform.data.wxnumber" :maxlength="20" placeholder="请输入微信号" />
          </el-form-item>
          <div class="flex aligncenter mb_10" v-if="zlform.type==1||zlform.type==2">
            <div class="f-14 c_000 s_title">{{zlform.type==1?'公众号二维码：':'微信二维码：'}}</div>
            <div class="flex aligncenter">
              <div class="sloganbox zfxbox flexcenter f-13 commhover">
                <img v-if="zlform.data.photo" :src="domain+zlform.data.photo" class="imgs" alt="">
                <span v-else>未设置</span>
                <div class="cover flexcolumn aligncenter justifycenter">
                  <input type="file" name="" accept="images/*" id="sharecode" class="sloganimg commhover" @change="upload($event,'sharecode')">
                  <span class="c_fff f-13">点击上传</span>
                </div>
              </div>
            </div>
            <div v-if="zlform.data.photo" class="commhover c_primary ml_20 f-15" @click="clearImg('sharecode')">清除</div>
          </div>
          <el-form-item label="关注引导词：" class="mb_0" v-if="zlform.type==1||zlform.type==2">
            <el-input  v-model="zlform.data.text" :maxlength="20" placeholder="扫码后回复：抽奖" />
          </el-form-item>
          <!-- 观看视频 -->
          <template v-if="zlform.type==3">
            <el-form-item label="跳转链接：" class="mb_10">
              <el-input  v-model="zlform.data.link" placeholder="跳转链接" />
            </el-form-item>
            <el-form-item label="是否限时" class="mb_10">
              <el-radio-group v-model="zlform.data.is_limit">
                <el-radio :label="1">
                  是
                  <template v-if="zlform.data.is_limit">
                    <el-input
                      type="number"
                      v-model="zlform.data.time"
                      size="small"
                      style="width: 100px"
                      class="pr_10 pl_10"
                      min="0"
                      max="100"
                      oninput="if(value > 100) value = 100; if(value < 0 || value == '' || value == null) value = 0;"
                    />
                    秒
                  </template>
                </el-radio>
                <el-radio :label="0">否</el-radio>
              </el-radio-group>
            </el-form-item>
            <el-form-item label="强制观看" class="mb_0">
              <el-radio-group v-model="zlform.data.is_force">
                <el-radio
                  v-for="(item, index) in statusList"
                  :key="index"
                  :label="item.id"
                  >{{ item.name }}</el-radio
                >
              </el-radio-group>
            </el-form-item>
          </template>
          <!-- 邀请好友 -->
          <template v-if="zlform.type==4">
            <el-form-item label="最低数量限制：" class="mb_0">
              <el-input  v-model="zlform.data.num" type="number" placeholder="最低数量限制" />
            </el-form-item>
          </template>
        </template>
      </div>
    </el-form>
    <!-- 抽奖赞助商设置 -->
    <div class="flexrowbetween pt_10 borderb mt_42">
      <div class="c_000">抽奖赞助商设置</div>
      <div class="c_primary f-14 commhover" v-if="sqtype5" @click="handleSq(5, 0)">
        收起 <i class="el-icon-arrow-up f-14"></i>
      </div>
      <div class="c_primary f-14 commhover" v-else @click="handleSq(5, 1)">
        展开 <i class="el-icon-arrow-down f-14"></i>
      </div>
    </div>
    <el-form :model="sponsorform"
      :rules="sponsorrules"
      ref="sponsorform"
      label-width="170px"
      label-position="left"
    >
      <div class="p_20 bg_F8F8F8" v-if="sqtype5">
        <!-- <div class="flex mb_10"> -->
        <el-form-item label="赞助商图片：" class="mb_18" prop="photo">
          <!-- <div class="f-14 c_000 s_title"></div> -->
          <div class="flex aligncenter">
            <div class="flex aligncenter">
              <div class="sloganbox zfxbox flexcenter f-13 commhover">
                <img v-if="sponsorform.photo" :src="sponsorform.photo" class="imgs" alt="">
                <span v-else>未设置</span>
                <div class="cover flexcolumn aligncenter justifycenter">
                  <input type="file" name="" accept="images/*" id="sponsor" class="sloganimg commhover" @change="upload($event,'sponsor')">
                  <span class="c_fff f-13">点击上传</span>
                </div>
              </div>
            </div>
            <div v-if="sponsorform.photo" class="commhover c_primary ml_20 f-15" @click="clearImg('sponsor')">清除</div>
          </div>
        </el-form-item>
        <el-form-item label="赞助商名称：" class="mb_18" prop="name">
          <el-input  v-model="sponsorform.name" placeholder="请输入赞助商名称" />
        </el-form-item>
        <el-form-item label="赞助商介绍：" class="mb_18" prop="introduce">
          <el-input  v-model="sponsorform.introduce" placeholder="请输入赞助商介绍" />
        </el-form-item>
        <el-form-item label="跳转链接：" class="mb_0" prop="url">
          <el-input  v-model="sponsorform.url" placeholder="请输入跳转链接" />
        </el-form-item>
      </div>
    </el-form>
    <!-- </el-form> -->
    <el-button type="primary" @click="save" class="mt_20">保存</el-button>
  </div>
</template>
<script>
import PfwComp from "./PfwComp.vue";
import { configEdit, configSave } from '@/api/active'
import { getDefaultData, taskInfo, taskHelpSave, taskSponsorSave } from '@/api/sethome'
import { uploadPhoto } from "@/api/comm";
import { isOverSize } from '@/utils/validate'
import { mapGetters, mapActions } from 'vuex'
import Citys from '@/components/Citys';

export default {
  data() {
    const equalToWin = (rule, value, callback) => {
      if (Number(value) > Number(this.form.win_num)) {
        callback(new Error("每人每项中奖次数不得大于每人抽奖总次数"));
      } else {
        callback();
      }
    };

    const equalToAll = (rule, value, callback) => {
      if (Number(value) > Number(this.form.all_num)) {
        // console.log('val',value, this.form.all_num)
        callback(new Error("每人每日抽奖获得次数不得大于每人抽奖总次数"));
      } else {
        callback();
      }
    };

    const equalToDay = (rule, value, callback) => {
      if (Number(value) < Number(this.form.user_day_num)) {
        callback(new Error("首次登录抽奖数不得低于每人每日抽奖获得次数"));
      } else {
        callback();
      }
    };

    return {
      taskid:'',
      status:0,
      statusList: [
        { name: "开启", id: 1 },
        { name: "关闭", id: 0 },
      ],
      fqlist: [
        { name: "关闭", id: '0' },
        { name: "12小时", id: '12' },
        { name: "24小时", id: '24' },
        { name: "48小时", id: '48' },
      ],
      helpList:[],
      sqtype: 1,
      sqtype2: 1,
      sqtype3: 1,
      sqtype4: 1,
      sqtype5:1,
      form: {
        game_limit_num:'',
        num:'',
        all_num:'',
        day_num:'',
        win_num:'',
        one_win_num:'',
        user_day_num:'',
        is_task:'',
        empty_chance:'',
        is_safe:0,
        is_limit:0,
        limit_province:'',
        limit_city:'',
        limit_area:'测试',
        type:'',
        forward_num:'',
        forward_limit_num:'',
        advert_num:'',
        advert_limit_num:'',
        mode_data:{
          chance:'',
          time:''
        },
        is_regard:'',
        // regard_data:{
        //   qrcode:'',
        //   text:''
        // }
      },
      rules:{
        all_num:[
          { required: true, trigger: "blur", message: "请输入每人抽奖总次数" },
          // { required: true, validator: equalToPassword, trigger: "blur" }
        ],
        day_num:[{ required: true, trigger: "blur", message: "请输入每人每天抽奖次数" }],
        win_num:[{ required: true, trigger: "blur", message: "请输入每人中奖次数" }],
        // one_win_num:[{ required: true, trigger: "blur", message: "请输入每人每项中奖次数" }],
        one_win_num:[
          { required: true, trigger: "blur", message: "请输入每人每项中奖次数" },
          { required: true, validator: equalToWin, trigger: "blur" }
        ],
        num:[
          { required: true, trigger: "blur", message: "请输入首次登录抽奖次数" },
          { required: true, validator: equalToDay, trigger: "blur" }
        ],
        user_day_num:[
          { required: true, trigger: "blur", message: "请输入每人每日抽奖获得次数" },
          { required: true, validator: equalToAll, trigger: "blur" }
        ],
        is_task:[{ required: true, trigger: "blur", message: "请选择获得额外机会" }],
      },
      citysParams:{},
      zlform:{
        type:'',
        status:0,
        data:{
          photo:'',//公众号||微信二维码
          text:'',//关注引导词
          link:'',//跳转链接
          is_limit:0,//是否限时
          is_force:0,//是否强制
          num:'',//最低数量限制
        }
      },
      zlrules:{},
      sponsorform:{
        url:'',
        name:'',
        photo:'',
        introduce:''
      },
      sponsorrules:{
        photo:[{ required: true, trigger: "blur", message: "请上传图片" }],
        name:[{ required: true, trigger: "blur", message: "请填写赞助商名称" }],
        introduce:[{ required: true, trigger: "blur", message: "请填写赞助商介绍" }],
        url:[
          { required: true, trigger: "blur", message: "请填写赞助商链接" },
          { pattern: /((http|https):\/\/([\w\-]+\.)+[\w\-]+(\/[\w\u4e00-\u9fa5\-\.\/?\@\%\!\&=\+\~\:\#\;\,]*)?)/ig, trigger: "blur", message: "请输入正确的链接",}
        ],
      },
    
      isRewirite:false,
      queryParams: {
        page: 1,
        num: 10,
      },
      total: 0,
      province:[],
      citys:[],
      region:[],
      cityform:{},
      peoperdisable:false
    };
  },
  computed: {
    ...mapGetters(["iframeUrl"]),
  },
  components: {
    PfwComp,Citys
  },
  props:{
    activeId:{
      default:''
    }
  },
  watch: {
    activeId:{
      immediate: false,
      handler: function (val){
        console.log('activeId有了--',val)
        this.taskid = val
      }
    }
  },
  watch:{
    'form.all_num':function(newValue){
     // 监听form表单中callPoliceSort字段值的变化，变化了将需要清空的值进行清空
      console.log('newValue',newValue);
      if(newValue>0){
        this.peoperdisable = true
        this.form.user_day_num = 0
      }
      if(newValue==0 && this.form.day_num==0){
        this.peoperdisable = false
      }
    },
    'form.day_num':function(newValue){
     // 监听form表单中callPoliceSort字段值的变化，变化了将需要清空的值进行清空
      console.log('newValue',newValue);
      if(newValue>0){
        this.peoperdisable = true
        this.form.user_day_num = 0
      }
      if(newValue==0 && this.form.all_num==0){
        this.peoperdisable = false
      }
    }
  },
  created(){
    // 
    this.taskid = this.activeId
    if(this.taskid){
      this.getInfo() //获取活动信息
    }else{
      this.getDefault() //获取默认参数
    }
    this.getDicts('/user/index_task/getHelpList').then(res=>{
      this.helpList = res.data
    })
  },
  methods: {
    ...mapActions(["setUrl"]),

    getDefault(){
      getDefaultData().then(res=>{
        let data = res.data
        this.form = data.config
        this.form.mode_data = {
          chance:'',
          time:'0'
        }
        this.form.regard_data = {
          qrcode:'',
          text:''
        }
      })
    },

    getInfo(){
      taskInfo({task_id:this.taskid}).then(res=>{
        let data = res.data
        this.status = data.task.status
        this.form = data.config
        // this.form.limit_province = ''
        // this.form.limit_city = ''
        // this.form.limit_area = ''

        if(Array.isArray(data.config.mode_data)){
          this.form.mode_data = {
            chance:'',
            time:''
          }
        }
        if(Array.isArray(data.config.regard_data)){
          this.form.regard_data = {
            qrcode:'',
            text:''
          }
        }
        if(data.sponsor){
          this.sponsorform = data.sponsor
        }
        if(data.help){
          this.zlform = data.help
          this.zlform.type = data.help.type+''
        }
        
      })
    },

    
    // handleEdit(e,index){
    //   console.log('11')
    //   let value = e.replace(/[^\d]/g, ""); // 只能输入数字
    //   value = value.replace(/^0+(\d)/, "$1"); // 第一位0开头，0后面为数字，则过滤掉，取后面的数字
    //   value = value.replace(/(\d{15})\d*/, '$1') // 最多保留15位整数
    //   this.advData[index].data.is_limit = value
    // },

    handleSq(type, status) {
      if (type == 1) {
        this.sqtype = status;
      } else if (type == 2) {
        this.sqtype2 = status;
      } else if (type == 3) {
        this.sqtype3 = status;
      }else if (type == 4) {
        this.sqtype4 = status;
      }else if (type == 5) {
        this.sqtype5 = status;
      }
    },

    handlerChange(){
      this.isRewirite = true
    },

    focus(){
      this.isRewirite = false
    },

    changeInput(){
      if(this.isRewirite){
        this.save()
      }
    },

    upload(event,type){
      var file = event.currentTarget.files[0];
      console.log("file:", file, event);
      if (isOverSize(file.size, 5)) {
        this.$message.warning("图片大小不能超过5MB");
        return;
      }
      var formData = new FormData();
      formData.append("file", file);
      formData.append("type", type);
      uploadPhoto(formData).then((res) => {
        if(type == 'adv_kp'){ 
          this.advData[0].data.url = res.data;
        }else if(type == 'adv_bottom'){
          this.advData[1].data.url = res.data;
        }else if(type == 'adv_tc'){
          this.advData[2].data.url = res.data;
        }else if(type == 'sharecode'){
          this.zlform.data.photo = res.data;
        }else if(type == 'sponsor'){
          this.sponsorform.photo = this.domain+res.data
        }
        document.getElementById(type).value = null;
      });
    },

    uploadVideo(event,type){
      var file = event.currentTarget.files[0];
      console.log("file:", file, event);
      // if (isOverSize(file.size, 5)) {
      //   this.$message.warning("视频大小不能超过5MB");
      //   return;
      // }
      var formData = new FormData();
      formData.append("file", file);
      formData.append("type", type);
      uploadPhoto(formData).then((res) => {
        if(type == 'adv_kp'){ 
          this.advData[0].data.url = res.data;
        }else if(type == 'adv_bottom'){
          this.advData[1].data.url = res.data;
        }else if(type == 'adv_tc'){
          this.advData[2].data.url = res.data;
        }
        document.getElementById(type).value = null;
      })
    },

    clearImg(type){
      if(type == 'adv_kp'){ 
        this.advData[0].data.url = '';
      }else if(type == 'adv_bottom'){
        this.advData[1].data.url = '';
      }else if(type == 'adv_tc'){
        this.advData[2].data.url = '';
      }else if(type == 'sharecode'){
        this.zlform.data.photo = '';
      }else if(type == 'sponsor'){
        this.sponsorform.photo = '';
      }
      document.getElementById(type).value = null;
    },

    changeCity(form){
      this.citysParams.province = form.province
      if(form.city){
        this.citysParams.city = form.city.split('_')[0];
      }
    },

    save(){
      this.$refs.ruleForm.validate(valid=>{
        if(!valid) return
        if(Number(this.form.one_win_num)>Number(this.form.win_num)){
          this.$message.warning('每人每项中奖次数不能大于每人中奖次数')
          return
        }
        // if(Number(this.form.user_day_num)>Number(this.form.all_num)){
        //   this.$message.warning('每人每日抽奖获得次数不能大于每人每人抽奖总次数')
        //   return
        // }
        // if(Number(this.form.num)<Number(this.form.user_day_num)){
        //   this.$message.warning('首次登录抽奖次数不能低于每人每日抽奖获得次数')
        //   return
        // }
        let sponsorValid = true
        this.$refs.sponsorform.validate(valid=>{
          sponsorValid = valid
        })
        if(!sponsorValid){
          this.$message.warning('请填写完整的抽奖赞助商信息')
          return
        }
        // console.log('this.taskid:',this.taskid)
        if(!this.taskid){
          this.$emit('saveAll')
          return
        }
        let params = {
          id:this.taskid,
          ...this.form
        }
        if(this.status == 1){
          configSave(params).then(res=>{
            this.setConfig()
          })
        }else{
          configEdit(params).then(res=>{
            this.setConfig()
          })
        }
      })
    },

    setConfig(){
      let zlparams = {
        id:this.taskid,
        status:this.zlform.status
      }
      if(this.zlform.status){
        zlparams = Object.assign({},zlparams,this.zlform)
      }
      Promise.all([taskHelpSave(zlparams),taskSponsorSave({...this.sponsorform,id:this.taskid})])
      .then(() => {
        // console.log('arr:',[response1, response2] response1, response2)
        this.$message.success('编辑成功')
        this.getInfo()
      })
      .catch(() => {
        console.log('-------报错')
      });
    },
  },
};
</script>
<style lang="scss" scoped>
.panel_h {
  height: calc(100vh - 239px);
  overflow-y: auto;
  padding-right: 12px;

  &::-webkit-scrollbar {
    /*滚动条整体样式*/
    width: 4px; /*高宽分别对应横竖滚动条的尺寸*/
    height: 1px;
  }
  &::-webkit-scrollbar-thumb {
    /*滚动条里面小方块*/
    border-radius: 10px;
    box-shadow: inset 0 0 5px rgba(97, 184, 179, 0.1);
    background: #c1c1c1;
  }
  &::-webkit-scrollbar-track {
    /*滚动条里面轨道*/
    box-shadow: inset 0 0 5px rgba(87, 175, 187, 0.1);
    border-radius: 10px;
    background: #ededed;
  }
}
.line {
  height: 82px;
}

.borderb {
  padding-bottom: 8px;
  border-bottom: 1px solid #F8F8F8;
}
::v-deep label {
  font-weight: normal;
}
::v-deep .el-form-item__label {
  color: #000;
  font-size: 14px;
}
.sloganbox {
  width: 180px;
  height: 90px;
  background-color: #fff;
  border-radius: 4px;
  color: #555;
  position: relative;
  overflow: hidden;

  &:hover .cover {
    display: flex !important;
  }
  .imgs{
    width: 100%;
    height: 100%;
  }
  .sloganimg{
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    opacity: 0;
  }
}
.bgbox {
  width: 120px;
  height: 210px;
}
.zfxbox{
  width: 120px;
  height: 120px;
}
.iconbox {
  width: 80px;
  height: 80px;
}
.s_title {
  width: 170px;
  // text-align: right;
  padding-right: 12px;
}
.cover {
  display: none;
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: rgba(0, 0, 0, 0.6);
}
.musicitem {
  padding: 10px;
}
.bg {
  background-color: #f3f3f4;
}
.circle{
  display: inline-block;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background-color: #0076FF;
  color: white;
  line-height: 26px;
  text-align: center;
}
.yell{
  background-color: #FFC069;
}
.redc{
  background-color: #F5222D;
}
</style>